<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer">
      <span class="todo-count"><strong>{{ allrenwu }}</strong>剩余</span>
      <ul 
      @click="$emit('changeType', type)"
      class="filters">
        <li>
          <a
          @click.prevent="type = 'all'"
          :class="{selected: type === 'all'}" 
          href="#/">全部</a>
        </li>
        <li>
          <a 
          @click.prevent="type = 'active'"
          :class="{selected: type === 'active'}" 
          href="#/active">进行中</a>
        </li>
        <li>
          <a 
          @click.prevent="type = 'completed'"
          :class="{selected: type === 'completed'}"
          href="#/completed">已完成</a>
        </li>
      </ul>
      <button 
      @click="ClearDone"
      v-show="showClear"
      class="clear-completed">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      repuired: true
    }
  },
  data() {
    return {
      type: 'all'
    };
  },
  methods: {
     ClearDone() {
      this.$emit('isClearDone')
     }
  },
  computed: {
    allrenwu() {
      return this.list.length
    },
    showClear() {
      return this.list.some(item => item.isDone)
    }
  }
};
</script>

<style lang="scss" scoped>

</style>